package com.butnet.myframe.hql.query;

import org.hibernate.Query;

/**
 * 查寻条件集
 * 
 * @author Butnet
 */
public class Wheres {
	private Where where = null;
	private String andOr = null;
	private Wheres another = null;
	private String objAsName = null;

	public Wheres() {
	}

	public Wheres(Where w) {
		where = w;
	}

	public Where getWhere() {
		return where;
	}

	public void setWhere(Where where) {
		this.where = where;
	}

	public String getAndOr() {
		return andOr;
	}

	public void setAndOr(String andOr) {
		this.andOr = andOr;
	}

	public Wheres getAnother() {
		return another;
	}

	public void setAnother(Wheres another) {
		this.another = another;
	}

	@Override
	public String toString() {
		if (andOr == null || another == null)
			return where.toString();
		return "( " + where.toString() + " " + andOr + " " + another.toString() + " )";
	}

	public void setParameters(Query q) {
		where.setParameters(q);
		if (another != null)
			another.setParameters(q);
	}

	public void setObjAsName(String name) {
		this.objAsName = name;
		where.setObjAsName(name);
		if (another != null)
			another.setObjAsName(name);
	}

	public String getObjAsName() {
		return objAsName;
	}
}
